package com.example.baseballgame;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends Activity {

	SoundPool pool;
	int sound;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_baseball_main);
		ImageView iv = (ImageView)findViewById(R.id.imageview);

		pool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		sound = pool.load(this, R.raw.waterdrop, 1);
		
		//int mWidth = this.getResources().getDisplayMetrics().widthPixels;
		//int mHeight = this.getResources().getDisplayMetrics().heightPixels;
		
		//Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.baseballs156x156);
		//Bitmap resized = Bitmap.createScaledBitmap(image, mWidth, mHeight, true);
		//iv.setImageBitmap(resized);
		//iv.setScaleType(ImageView.ScaleType.FIT_XY);
		//iv.setPadding(3, 3, 3, 3);
		iv.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				switch(event.getAction()){
				case MotionEvent.ACTION_DOWN :
					//Toast.makeText(MainActivity.this, "Game Start!", Toast.LENGTH_SHORT).show();
					pool.play(sound, 1, 1, 0, 0, 1);
					Intent intent = new Intent(MainActivity.this, RuleActivity.class);
					startActivity(intent);
				break;
				}
				
				return false;
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
